package com.zengge.zbc.mapper;


import com.zengge.zbc.po.UserInfo;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {


    @Select({"SELECT * FROM user_info WHERE user_id=#{userId} FOR UPDATE"})
    @Results(id = "userInfoResult",value = {
            @Result(id = true,column = "object_id",property = "objectId"),
            @Result(column = "user_id",property = "userId"),
            @Result(column = "union_id",property = "unionId"),
            @Result(column = "session_key",property = "sessionKey"),
            @Result(column = "create_time",property = "createTime"),
            @Result(column = "update_time",property = "updateTime"),


    })
    UserInfo findUserInfoByUserId(@Param("userId") String openid);


    @Insert({"INSERT INTO user_info (object_id,user_id,union_id,session_key,create_time,update_time) " +
            "VALUES(#{objectId},#{userId},#{unionId},#{sessionKey},#{createTime},#{updateTime})"})
    void save(UserInfo userInfo);



    @Update({"UPDATE user_info SET user_id=#{userId},union_id=#{unionId},session_key=#{sessionKey}," +
            "update_time=#{updateTime} WHERE object_id=#{objectId}"})
    void update(UserInfo userInfo);
}
